import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/public/public_date.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import '../../model/account_withdraw_history_model.dart';
import 'logic.dart';

class AccountWithdrawHistoryInfoPage extends StatefulWidget {
  const AccountWithdrawHistoryInfoPage({Key? key}) : super(key: key);

  @override
  State<AccountWithdrawHistoryInfoPage> createState() => _AccountWithdrawHistoryInfoPageState();
}

class _AccountWithdrawHistoryInfoPageState extends State<AccountWithdrawHistoryInfoPage> {
  final AccountWithdrawHistoryInfoLogic logic = Get.put(AccountWithdrawHistoryInfoLogic());

  late AccountWithdrawHistoryItemModel itemModel;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    itemModel = Get.arguments;
  }

  /*
  * 获取状态
  * */
  String getStatusTitle() {
    if (itemModel.state == null) {
      return "";
    }
    String title = "";
    if (itemModel.state == 5) {
      title = "提现成功";
    } else if (itemModel.state == 1) {
      title = "审核中";
    } else if (itemModel.state == 2) {
      title = "审核中";
    } else {
      title = "提现失败(已退回)";
    }
    return title;
  }

  /*
  * 获取状态颜色
  * */
  Color getStatusColor() {
    if (itemModel.state == null) {
      return MGColors.text3Color;
    }
    Color color;
    if (itemModel.state == 5) {
      color = MGColors.greenColor;
    } else if (itemModel.state == 1) {
      color = MGColors.blueColor;
    } else if (itemModel.state == 2) {
      color = MGColors.blueColor;
    } else {
      color = MGColors.redColor;
    }
    return color;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "提现详情"),
      body: MGCard(
        margin: EdgeInsets.only(left: 12, right: 12, top: 12),
        children: [
          MGItems(
            leadTitle: "提现信息",
            leadStyle: TextStyle(
              color: MGColors.text1Color,
              fontWeight: FontWeight.bold,
              fontSize: MGFont.textFont1,
            ),
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "提现金额",
            trailingTitle: "${(itemModel.amount ?? 0.00).toStringAsFixed(2)}元",
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "手续费",
            trailingTitle: "${(itemModel.serviceFee ?? 0.00).toStringAsFixed(2)}元",
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "到账金额",
            trailingTitle: "${((itemModel.amount ?? 0.00) - (itemModel.serviceFee ?? 0.00)).toStringAsFixed(2)}元",
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "提现方式",
            trailingTitle: itemModel.watWithdrawPayTypeDisplayName,
            showBottomSplit: true,
          ),
          (itemModel.watWithdrawPayType == 4)
              ? MGItems(
                  leadTitle: "手机号",
                  trailingTitle: itemModel.tmcBankAccountReservedPhoneNumber,
                  showBottomSplit: true,
                )
              : Container(),
          (itemModel.watWithdrawPayType == 4)
              ? MGItems(
                  leadTitle: "银行卡号",
                  trailingTitle: itemModel.tmcBankAccountBankCardNumber,
                  showBottomSplit: true,
                )
              : Container(),
          MGItems(
            leadTitle: "申请时间",
            trailingTitle: HLDate.hl_formatDate(itemModel.createTime),
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "提现状态",
            trailingTitle: getStatusTitle(),
            trailingStyle: TextStyle(fontSize: MGFont.textFont2, color: getStatusColor()),
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "交易单号",
            trailingTitle: itemModel.paymentNo,
            showBottomSplit: true,
          ),
          MGItems(
            leadTitle: "审批备注",
            trailingTitle: itemModel.remark,
          )
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<AccountWithdrawHistoryInfoLogic>();
    super.dispose();
  }
}
